package classesdemo;

import org.apache.commons.lang3.ArrayUtils;

import java.io.IOException;
import java.util.Arrays;

/**
 * Created by pc on 2015/2/12.
 */
public class QuickTest {
//    static Object nullTest;
    public static void main(String args[]) throws IOException {


        //这样写也合法？
        int []arr[] = new int[4][4];
        System.out.println("length:" + arr.length);

        //最终x是几？
        int x = 3;
        x = x + (x++) + (++x) ;
        System.out.println("x + (x++) + (++x) = " + x );

        Integer values []  = new Integer[10];
        Arrays.fill(values, 1);
        int intValues [] = ArrayUtils.toPrimitive(values);
        System.out.println(Arrays.toString(intValues));

        //System.identifyHashCode
//        String t1 = new String("haha");
//        String t2 = new String("haha");
//        System.out.println(System.identityHashCode(t1));
//        System.out.println(System.identityHashCode(t1) == System.identityHashCode(t2));
//        System.out.println(t1.hashCode() + "-----" + t2.hashCode());
//        System.out.println(t1.hashCode() == t2.hashCode());
//        System.out.println(t1.equals(t2));

        //Objects.requireNonNull test
//        QuickTest.nullTest = 60;
//        System.out.println("test: " + Objects.requireNonNull(nullTest, "Oh, null found!"));

        //BigDecimal demo
//        float a = 2.34f;
//        float b = 3.02f;
//        System.out.println("2.34 -3.02=" + (b-a));
//        BigDecimal ba = new BigDecimal("0.05");
//        BigDecimal ba1 = new BigDecimal("0.01");
//        System.out.println("get xxx: " + ba.add(ba1));
//        ba = ba.add(BigDecimal.valueOf(0.01));
//        System.out.println("get: " + ba);
//        System.out.println("aaa: " + (BigDecimal.valueOf(2.04 + 3.45)));


        //遍历properties
/*        for(Map.Entry<Object, Object> entry: System.getProperties().entrySet()){
            System.out.println(entry.getKey() + "--" + entry.getValue());
        }*/


        //运行系统命令
//        Runtime rt = Runtime.getRuntime();
//        rt.exec("C:\\Users\\pc\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
//        System.out.println(Runtime.getRuntime().availableProcessors());

        //Collection里放的全是对象的引用，不是对象
//        Hashtable ht = new Hashtable();
//        StringBuffer sb = new StringBuffer();
//        sb.append("abc,");
//        ht.put("1",sb);
//        sb.append("def,");
//        ht.put("2",sb);
//        sb.append("mno,");
//        ht.put("3",sb);
//        sb.append("xyz.");
//        ht.put("4",sb);
//        int numObj=0;
//        Enumeration it = ht.elements();
//        while(it.hasMoreElements()){
//            System.out.print("get StringBufffer "+(++numObj)+" from Hashtable: ");
//            System.out.println(it.nextElement());
//        }
    }

}

